from django.db import models


# Create your models here.
class Employees(models.Model):
    '''员工类'''
    empno = models.IntegerField(primary_key=True, verbose_name='员工编号')
    ename = models.CharField(max_length=50, verbose_name='员工姓名')
    job = models.CharField(max_length=50, verbose_name='员工职位')
    mgr = models.IntegerField(verbose_name='上级工号', null=True)
    hiredate = models.DateField(verbose_name='入职日期')
    sal = models.DecimalField(verbose_name='薪资', max_digits=7, decimal_places=2)
    dept = models.ForeignKey('Department', on_delete=models.CASCADE)

    class Meta:
        db_table = 'tb_emp'

    def __str__(self):
        return self.ename


class Department(models.Model):
    '''部门类'''
    deptno = models.IntegerField(primary_key=True, verbose_name='部门编号')
    dname = models.CharField(max_length=20, verbose_name='部门名称')
    dlocal = models.CharField(max_length=20, verbose_name='部门地点')

    class Meta:
        db_table = 'tb_dept'

    def __str__(self):
        return self.dname